home *** CD-ROM | disk | FTP | other *** search
/ Complete Linux / Complete Linux.iso / docs / apps / database / ingres04.lzh / source / ctlmod / do_st.c < prev    next >
Encoding:
C/C++ Source or Header  |  1985-01-23  |  2.1 KB  |  99 lines

  1. # include    "ctlmod.h"
  2. # include    "pipes.h"
  3. # include    <sccs.h>
  4.  
  5. SCCSID(@(#)do_st.c    8.1    12/31/84)
  6.  
  7. /*
  8. **  DO_ST -- do a state.
  9. **
  10. **    This routine does a state as indicated by ppb, handing it
  11. **    pc & pv as parameters.  The state must be known already.
  12. **
  13. **    If the state is local, it calls 'call_fn' to actually
  14. **    do the setup and call the function.
  15. **    If the state is remote, it uses send_off to send ppb
  16. **    to the process that can do it.
  17. **
  18. **    It returns the next state to execute, possibly PB_UNKNOWN.
  19. **
  20. **    Parameters:
  21. **        ppb -- a pipe block which identifies the state
  22. **            to call, etc.
  23. **        pc -- the pc to hand to the function.
  24. **        pv -- the pv to had to the function.
  25. **
  26. **    Returns:
  27. **        none (except through ppb)
  28. **
  29. **    Side Effects:
  30. **        *ppb gets set to identify the next state.
  31. **        Resp is set if local function.
  32. **
  33. **    Called By:
  34. **        do_seq
  35. **
  36. **    Trace Flags:
  37. **        2.8 - 2.15
  38. */
  39.  
  40. do_st(ppb, pc, pv)
  41. register pb_t    *ppb;
  42. int        pc;
  43. PARM        *pv;
  44. {
  45.     register state_t    *s;
  46.     register int        i;
  47.     int            rtval;
  48.  
  49.     i = ppb->pb_st;
  50.     s = &Cm.cm_state[i];
  51.     if (i < 0 || i > CM_MAXST || s->st_type == ST_UNDEF)
  52.         syserr("do_st: undef state %d", i);
  53. # ifdef xCTR1
  54.     if (tTf(2, 8))
  55.         lprintf("do_st: state %d type %d mark %d\n",
  56.             i, s->st_type, markbuf(Qbuf));
  57. # endif
  58.  
  59.     switch (s->st_type)
  60.     {
  61.       case ST_REMOT:
  62.         /*
  63.         **  Remote: determine the correct process and send
  64.         **  it on its way.
  65.         */
  66.  
  67.         ppb->pb_proc = s->st_v.st_rem.st_proc;
  68.         send_off(ppb, pc, pv);
  69.         pb_flush(ppb);
  70.         rtval = PB_UNKNOWN;
  71.         break;
  72.  
  73.       case ST_LOCAL:
  74.         /*
  75.         **  Local: execute the function using 'call_fn'
  76.         **  and compute next state.
  77.         **  If call originated in this process, set the EOF bit
  78.         **  so we don't try to read this pipe later.
  79.         */
  80.  
  81.         if (bitset(PB_FRFR, ppb->pb_stat) && !bitset(ST_EXTERN, s->st_stat))
  82.             syserr("do_st: restricted state %d", i);
  83.         if (ppb->pb_from == Cm.cm_myproc)
  84.             setbit(PB_EOF, ppb->pb_stat);
  85.         call_fn(s->st_v.st_loc.st_funcno, pc, pv);
  86.         rtval = s->st_v.st_loc.st_next;
  87.         break;
  88.  
  89.       default:
  90.         syserr("do_st: type %d", s->st_type);
  91.     }
  92.  
  93. # ifdef xCTR1
  94.     if (tTf(2, 10))
  95.         lprintf("do_st: ret %d mark %d\n", rtval, markbuf(Qbuf));
  96. # endif
  97.     return (rtval);
  98. }
  99.